﻿@{
    ViewBag.Title = "管理日志";
}
<div class="pageheader">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
            <li><a href="javascript:;">管理日志</a> </li>
        </ul>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-card layui-tab">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="menu-list">
                        <div class="layui-inline">
                            <div class="layui-input-inline mr0">
                                <input id="txtKeywords" class="layui-input" type="text" placeholder="输入关键字" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn layui-btn-normal layui-btn-sm" id="btnSearchAuth" data-type="btnSearch">
                                <i class="layui-icon">&#xe615;</i>搜索
                            </button>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <a data-type="btnDelete" href="javascript:;" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="iconfont icon-delete"></i><span> 删除日志</span></a>
                        <input name="dateRange" type="text" class="input rule-date-input">
                    </div>
                </div>
            </div>
            <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                <thead>
                    <tr>
                        <th lay-data="{checkbox:true}"></th>
                        <th lay-data="{field:'user_name'}">用户名</th>
                        <th lay-data="{field:'action_type'}">操作类型</th>
                        <th lay-data="{field:'remark'}">备注</th>
                        <th lay-data="{field:'user_ip'}">用户IP</th>
                        <th lay-data="{field:'add_time'}">添加时间</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
@section Scripts{
    <script type="text/javascript">
        layui.use(['table', 'cmswh', 'laydate'], function () {
            var table = layui.table, form = layui.form, cmswh = layui.cmswh, laydate = layui.laydate,$=layui.jquery;
            laydate.render({
                elem: '#txtStartTime'
            });
            laydate.render({
                elem: '#txtEndTime'
            });
            laydate.render({
                elem: 'input[name="dateRange"]',
                type: 'date',
                range: true,
                trigger: 'click'
            });

            cmswh.dataBind('ManagerLogList');
            var fun = {
                btnDelete: function () {
                    cmswh.batOperate('ManagerLogDelete', 'id', "删除7天前的管理日志，你确定吗？");
                },
                btnSearch: function () {
                    //执行重载
                    table.reload('ltable', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        , where: getcond()
                    });
                }
            };
            $('.layui-inline .layui-btn').on('click', function () {
                var type = $(this).data('type');
                fun[type] ? fun[type].call(this) : '';
            });
            /*拼接条件返回postdata*/
            function getcond() {
                var Date = $('input[name="dateRange"]').val(), starttime, endtime;
                if (Date) {
                    var searchDate = Date.split(' - ');
                    starttime = searchDate[0];
                    endtime = searchDate[1];
                }
                var keywords = $("#txtKeywords").val();
                var postdata = { start: starttime, end: endtime, keywords: keywords };
                return postdata;
            }
        });
    </script>
}
